home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from apt_pkg import ParseTagFile, PkgSystemLock, PkgSystemUnLock
- import subprocess
- import logging
- import computerjanitor
- _ = computerjanitor.setup_gettext()
-
- class DpkgStatusCruft(computerjanitor.Cruft):
-
- def __init__(self, n_items):
- self.n_items = n_items
-
-
- def get_prefix(self):
- return 'dpkg-status'
-
-
- def get_prefix_description(self):
- return _('%i obsolete entries in the status file') % self.n_items
-
-
- def get_shortname(self):
- return _('Obsolete entries in dpkg status')
-
-
- def get_description(self):
- return _('Obsolete dpkg status entries')
-
-
- def cleanup(self):
- logging.debug('calling dpkg --forget-old-unavail')
- res = subprocess.call([
- 'dpkg',
- '--forget-old-unavail'])
- logging.debug('dpkg --forget-old-unavail returned %s' % res)
-
-
-
- class DpkgStatusPlugin(computerjanitor.Plugin):
-
- def __init__(self, fname = '/var/lib/dpkg/status'):
- self.status = fname
- self.condition = [
- 'PostCleanup']
-
-
- def get_cruft(self):
- n_cruft = 0
- tagf = ParseTagFile(open(self.status))
- while tagf.Step():
- statusline = tagf.Section.get('Status')
- (want, flag, status) = statusline.split()
- if want == 'purge' and flag == 'ok' and status == 'not-installed':
- n_cruft += 1
- continue
- logging.debug('DpkgStatusPlugin found %s cruft items' % n_cruft)
- if n_cruft:
- return [
- DpkgStatusCruft(n_cruft)]
- return []
-
-
-